﻿#include <iostream>
#include<string>
using namespace std;
int main()
{
	char a[205];
	int b,s,k,n=0,m=0,fg=0;
	cin >> a >> b;
	s = strlen(a);
	k = s;
	for (int i = 0; i < s; i++)
	{
		if (a[i] == '6') { n++; s--; }
		else if (a[i] == '9') { m++; s--; }
	}
	if (b>s)
	{
		if (m == 0)cout << "qwq臣妾做不到呀";
		if (m != 0)for (int i = 0; i < k; i++)
		{
			if (a[i] == '9' && fg == 0)for (int j = 0; j < b - s; j++) { cout << a[i - 1]; fg = 1; }
			else if (a[i] != '6' && a[i] != '9')cout << a[i];
		}
	}
	else if (b == s)
	{
		for (int i = 0; i < k; i++)
			if (a[i] != '6' && a[i] != '9')
				cout << a[i];
	}
	else if (b >= s - m - n)for (int i = 0; i < k; i++)
	{
		if ((a[i + 1] == '6' || a[i + 1] == '9') && fg < s - b) { fg++; }
		else if (a[i] != '6' && a[i] != '9')cout << a[i];
	}
	else if (m == 0)cout << "qwq臣妾做不到呀";
}